package com.smile.f315;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JPanel;
class FontPanel extends JPanel{
	public void paintComponent(Graphics g){
		super.paintComponents(g);
		Graphics2D g2 = (Graphics2D)g;
		
		//使用默认字体绘制文本
		String text = "The brown fox jumped over the lazy dog";
		g2.drawString(text, 0, 20);
		
		//使用指定颜色绘制文本
		g2.setColor(Color.RED);
		g2.drawString(text, 0, 40);
		
		//使用指定字体和风格绘制文本
		Font font = new Font("Arial",Font.BOLD+Font.ITALIC,14);
		g2.setFont(font);
		g2.drawString(text, 0, 60);
	}
}
public class FontDemo {
	public void createUI(){
		JFrame frame = new JFrame("边框属性示例程序");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		FontPanel panel = new FontPanel();
		frame.add(panel);
		
		frame.setBounds(200, 200, 250, 120);
		frame.setVisible(true);
	}
	public static void main(String[] args) {
		FontDemo example = new FontDemo();
		example.createUI();
	}
}